package com.test;

/*
import java.net.InetAddress;

public class Example01 {
    public static void main(String[] args) throws Exception {
        InetAddress localAddress = InetAddress.getLocalHost();
        InetAddress remoteAddress = InetAddress.getByName("www.itcast.cn");
        System.out.println("本机的IP地址：" + localAddress.getHostAddress());
        System.out.println("www.itcast.cn的IP地址："+remoteAddress.getHostAddress());
        System.out.println("3秒是否可达主机名为www.itcast.cn的ip地址："+remoteAddress.isReachable(3000));
    }
}

 */

import java.io.InputStream;
import java.net.URL;
import java.util.Scanner;

public class Example01 {
    public static void main(String[] args) throws Exception {
        URL url = new URL("http", "www.itcast.cn", 80, "/subject/uidszly/index.html");
        InputStream input = url.openStream();
        Scanner scan = new Scanner(input);
        scan.useDelimiter("\n");
        //用于设置Scanner对象的分隔符。
        while(scan.hasNext()) {
            System.out.println(scan.next());
        }
    }
}
